package shapes.shapes2D.distribution.trigo 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	import samples.BaseSample;
	import shapes.shapes2D.polygon.Edge;
	import shapes.shapes2D.polygon.triangle.Triangle;
	import shapes.shapes2D.polygon.triangle.TriangleUtils;
	
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class LawOfCosine extends BaseSample
	{
		
		private var radius:Number = 150;
		private var angle:Number = 0;
		private var triangle:Triangle;
		public function LawOfCosine() 
		{
			
			triangle = new Triangle( 
										new Point( 100, 100 ),
										new Point( 600, 150 ),
										new Point( 250, 450 )
									);
									
			addEventListener( Event.ENTER_FRAME, update );
			
			
		}
		
		private function update(e:Event):void 
		{
			graphics.lineStyle( 0, 0xfFFFFF );
			triangle.draw( graphics );
			
			var edge:Edge;
			
			for ( var i:int = 0; i < 3; i++ )
			{
			
				edge = TriangleUtils.median( triangle, i );
				graphics.lineStyle( 0, 0xfF0000 );
				edge.draw( graphics );
				
				
				edge = TriangleUtils.height( triangle, i );
				graphics.lineStyle( 0, 0x00fF00 );
				if( edge != null ) edge.draw( graphics );
			
			}
		}
		
	}

}